﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleDispatch.DispatchConfig
{
    /// <summary>
    /// 节点配置
    /// </summary>
    public class FolwNodeConfig
    {
        /// <summary>
        /// 节点组枚举
        /// </summary>
        public Dictionary<FolwNodeGroupEnum, List<FolwNodeInfo>> FolwNodeGroup = new Dictionary<FolwNodeGroupEnum, List<FolwNodeInfo>>();


        public FolwNodeConfig()
        {
            Init();
        }

        public void Init()
        {
            FolwNodeGroupConfig();
        }


        /// <summary>
        /// 节点组配置
        /// </summary>
        private void FolwNodeGroupConfig()
        {
            var group1FolwNodes = new List<FolwNodeInfo>();
            group1FolwNodes.Add(FolwNodeInfo.CreateObj(FolwNodeEnum.FolwNode1, 1));
            group1FolwNodes.Add(FolwNodeInfo.CreateObj(FolwNodeEnum.FolwNode2, 2));
            group1FolwNodes.Add(FolwNodeInfo.CreateObj(FolwNodeEnum.FolwNode3, 3));
            FolwNodeGroup.Add(FolwNodeGroupEnum.FolwNodeGroup1, group1FolwNodes);

            var group2FolwNodes = new List<FolwNodeInfo>();
            group1FolwNodes.Add(FolwNodeInfo.CreateObj(FolwNodeEnum.FolwNode4, 1));
            group1FolwNodes.Add(FolwNodeInfo.CreateObj(FolwNodeEnum.FolwNode5, 2));
            FolwNodeGroup.Add(FolwNodeGroupEnum.FolwNodeGroup2, group2FolwNodes);

            var group3FolwNodes = new List<FolwNodeInfo>();
            group1FolwNodes.Add(FolwNodeInfo.CreateObj(FolwNodeEnum.FolwNode6, 1));
            group1FolwNodes.Add(FolwNodeInfo.CreateObj(FolwNodeEnum.FolwNode7, 2));
            FolwNodeGroup.Add(FolwNodeGroupEnum.FolwNodeGroup3, group3FolwNodes);
        }
    }


    /// <summary>
    /// 节点信息
    /// </summary>
    public class FolwNodeInfo
    {
        /// <summary>
        /// 节点
        /// </summary>
        public FolwNodeEnum FolwNode { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        public int Index { get; set; }

        /// <summary>
        /// 创建对象
        /// </summary>
        /// <param name="folwNode"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public static FolwNodeInfo CreateObj(FolwNodeEnum folwNode, int index)
        {
            return new FolwNodeInfo
            {
                FolwNode = folwNode,
                Index = index
            };
        }
    }

    /// <summary>
    /// 节点组信息
    /// </summary>
    public class FolwNodeGroupInfo
    {
        /// <summary>
        /// 节点
        /// </summary>
        public FolwNodeGroupEnum FolwNodeGroup { get; set; }

        /// <summary>
        /// 父级id
        /// 如果是初始节点，那么赋予初始化父节点组
        /// </summary>
        public FolwNodeGroupEnum FolwNodeGroupParent { get; set; }


        /// <summary>
        /// 创建对象
        /// </summary>
        /// <param name="folwNode"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public static FolwNodeGroupInfo CreateObj(FolwNodeGroupEnum FolwNodeGroup, FolwNodeGroupEnum folwNodeGroupParent)
        {
            return new FolwNodeGroupInfo
            {
                FolwNodeGroup = FolwNodeGroup,
                FolwNodeGroupParent = folwNodeGroupParent
            };
        }
    }



}
